<template>
  <div :class="cssLink?'h5':'web'">
    <div class="hello-page">
    <div class="nav-name">
      <!-- <img src="../../assets/wzz_image/wzzlog.png" alt=""> -->
      <div>伍子醉可视化界面导航</div>
    </div>
    <div class="nav-box">
      <!-- http://172.20.109.1:8080/ -->
      <!-- http://172.20.100.119:9091/ -->
      <a href="http://172.20.100.119:9091/" target="_self">
        <div class="nav-list">
          <div>
            <div class="nav-icon">
              <el-icon :size="cssLink?'.28rem':'28'" color="#fff">
                <Calendar />
              </el-icon>
            </div>
            <div class="nav-title">设备采集</div>
          </div>
        </div>
      </a>
      <div class="nav-list" v-for="(item,index) in navlistData" :key="index" @click="toLink(item)" v-if="index!=0">
        <div>
          <div class="nav-icon">
            <el-icon :size="cssLink?'.28rem':'28'" color="#fff">
              <Calendar />
            </el-icon>
          </div>
          <div class="nav-title">{{ item.meta.title }}</div>
        </div>
      </div>
    </div>
  </div>
</div>


</template>

<script setup>
import router, { constantRoutes, dynamicRoutes } from '@/router'
    const { proxy } = getCurrentInstance();
    let navlistData =ref([])
    const toLink=(item)=>{
      console.log(item)
      proxy.$router.push({
        path: item.path,
        query: {}
      })
    }

    const cssLink = ref(false);
    onMounted(() => {
      cssLink.value = window.innerWidth<1300?true:false;
      let navlist=[]
      constantRoutes.map(item =>{
        if(item.children){
          navlist=navlist.concat(item.children)
        }
        
      })
      navlistData.value=navlist
    })


</script>
<style scoped lang="scss">
    .hello-page {
      background: url("../../assets/wzz_image/nav-bg.png") no-repeat;
      background-size: 100% 100%; /* 让背景图片等比例拉伸或缩小以填满容器 */
      box-sizing: border-box;
      width: 100%; /* 设置宽度为父容器的100% */
      height: 100vh; /* 设置高度为父容器的100% */
      overflow: hidden;
    }
.h5{
  .nav-name{
    text-align: center;
    font-size: .42rem;
    color: #fff;
    margin:.3rem 0 .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    img{
      width: 1.2rem;
      margin-right: .2rem;
    }
  }
  .nav-box{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  
    width: 12rem;
    margin:0 auto;
    .nav-list{
      width: 2.2rem;
      height: 3rem;
      margin: .1rem;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: .2rem;
      border: 1px solid rgba(255,255,255,.2);
      &:nth-child(odd){
        background-color: #106dfd;
      }
      &:nth-child(even){
        background-color: #2c81eb;
      }
      &:hover{
        background-color: #4a5bf1;
      }
      .nav-icon{
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        margin:0 auto .2rem !important;
        height: .6rem;
        width: .6rem;
        border-radius: 50%;
        border: 1px solid #fff;
      }
      .nav-title{
        color: #fff;
        font-size: .16rem;
        text-align: center;
      }
    }
  }

}
  .web{
    .nav-name{
      text-align: center;
      font-size: 42px;
      color: #fff;
      margin:30px 0 60px;
      display: flex;
      align-items: center;
      justify-content: center;
      img{
        width: 120px;
        margin-right: 20px;
      }
    }
    .nav-box{
      display: flex;
      align-items: center;
      flex-wrap: wrap;
    
      width: 1200px;
      margin:0 auto;
      .nav-list{
        width: 220px;
        height: 300px;
        margin: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        border: 1px solid rgba(255,255,255,.2);
        &:nth-child(odd){
          background-color: #106dfd;
        }
        &:nth-child(even){
          background-color: #2c81eb;
        }
        &:hover{
          background-color: #4a5bf1;
        }
        .nav-icon{
          text-align: center;
          display: flex;
          align-items: center;
          justify-content: center;
          margin:0 auto 20px !important;
          height: 60px;
          width: 60px;
          border-radius: 50%;
          border: 1px solid #fff;
        }
        .nav-title{
          color: #fff;
          font-size: 16px;
          text-align: center;
        }
      }
    }

  }
</style>